a = [9, 8, [1, 2], 6]
b = a.copy()
print(a, b)
a.append(2)
b.append(3)
print("第一层：", a, b)  # 没有发生改变
a[2].append(3)
b[2].append(4)
print("第二层：", a, b)  # 发生改变
"""
[9, 8, [1, 2], 6] [9, 8, [1, 2], 6]
[9, 8, [1, 2], 6, 2] [9, 8, [1, 2], 6, 3]
[9, 8, [1, 2, 3, 4], 6, 2] [9, 8, [1, 2, 3, 4], 6, 3]
"""

print("*" * 80)
import copy

a = {1: [1, 2, 3]}  # 深拷贝会重新开辟一个内存空间
c = copy.deepcopy(a)
print(a, c)
a[1].append(4)
c[1].append(5)
print(a, c)
"""
{1: [1, 2, 3]} {1: [1, 2, 3]}
{1: [1, 2, 3, 4]} {1: [1, 2, 3, 5]}

浅拷贝只拷贝数据的第一层，深层的数据会被改变[9, 8, [1, 2], 6]
深拷贝重新开辟一个内存空间，深层不会被影响
"""
